﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kortex.Network_mapper;
using Kortex.Communication_objs;
using Kortex.Ident_manager;

namespace Kortex.AllCommandsSpace
{
    public class CommandHandleKP
    {
        public NetworkMapper sdVideoService;
        public NetworkMapper sdPanelService;
        public NetworkMapper sdFpgaService;
        public NetworkMapper sdSysMgrService;
        public NetworkMapper sdInputService;
        public NetworkMapper sdColorService;
        //NetworkMapper sdSysMgrService;
        
        IdentManager idMfr;


       public CommandHandleKP(IdentManager IdObj)
        {
           idMfr = IdObj;
        }


       public void Proc_rev_responces()
       {
           
           sdInputService.Proc_recv_responce();
           sdPanelService.Proc_recv_responce();
           sdSysMgrService.Proc_recv_responce();
           sdColorService.Proc_recv_responce();
 
       
       }

       public void ConnectTosdVideoService(string server, int port)
        {

            //sdVideoService.Connect2Server(server, port);
           
        }

       public void ConnectTosdPanelService(string server, int port)
       {

           sdPanelService.Connect2Server(server, port);
       }

       public void ConnectTosdFpgaService(string server, int port)
       {

           sdFpgaService.Connect2Server(server, port);
       }

       public void ConnectTosdSysMgrService(string server, int port)
       {

           sdSysMgrService.Connect2Server(server, port);
       }

       public void ConnectTosdInputService(string server, int port)
       {

           sdInputService.Connect2Server(server, port);
       }

       public void ConnectTosdColorService(string server, int port)
       {

           sdColorService.Connect2Server(server, port);
       }




       #region Optimize Connect

       public void ConnectTosdVideoService(string server, int port,bool Optmiz)
       {

           //sdVideoService.Connect2Server(server, port);

       }

       public void ConnectTosdPanelService(string server, int port,bool Optmiz)
       {

           sdPanelService.Connect2Server(server, port, Optmiz);
       }

       public void ConnectTosdFpgaService(string server, int port, bool Optmiz)
       {

           sdFpgaService.Connect2Server(server, port, Optmiz);
       }

       public void ConnectTosdSysMgrService(string server, int port, bool Optmiz)
       {

           sdSysMgrService.Connect2Server(server, port, Optmiz);
       }

       public void ConnectTosdInputService(string server, int port, bool Optmiz)
       {

           sdInputService.Connect2Server(server, port, Optmiz);
       }

       public void ConnectTosdColorService(string server, int port, bool Optmiz)
       {

           sdColorService.Connect2Server(server, port, Optmiz);
       }




       #endregion

       public void DisConnectFromServr()
        {
            if (sdSysMgrService != null)
            sdSysMgrService.DisconnectFromServer();

            if (sdFpgaService != null)
            sdFpgaService.DisconnectFromServer();

            if (sdPanelService != null)
            sdPanelService.DisconnectFromServer();
            //sdVideoService.DisconnectFromServer();
            
            if (sdInputService != null)
            sdInputService.DisconnectFromServer();
            
            if (sdColorService != null)
            sdColorService.DisconnectFromServer();
        }



        #region General Tab Commands


        public int updateFirmware(string fmwType, string path,string bank)
        {
            int id = idMfr.getNextIdent();
            UpdateFmw_obj_req obj = new UpdateFmw_obj_req("firmware_update", "2.0", id, fmwType, path, bank);

            sdSysMgrService.GeneralSet(obj);
            return id;
        }


        public int saveALL()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("trigger_settings_saveall", "2.0", id,0);

            sdSysMgrService.GeneralGet(obj);
            //sdSysMgrService.GeneralGet(obj);
            return id;

        }

       

        


        public int Getfmw_update_status(string rpcid)
        {
            int id = idMfr.getNextIdent();
            //Getfmw_updateStatus_req
            Getfmw_updateStatus_req obj = new Getfmw_updateStatus_req("get_rpc_req_status", "2.0", id, rpcid);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int SetOperationState(string state)
        {
            int id = idMfr.getNextIdent();
            stateChangeSet_Obj_req obj = new stateChangeSet_Obj_req("set_device_operation", "2.0", id, state);

            sdSysMgrService.OpretationStateSet(obj);
            return id;

        }

        public int UploadFmw_viaTftp(string srcaddr_p, string targetpath_p, string srcfile_p)
        {
            int id = idMfr.getNextIdent();
            UpLoadTftpFile_Obj_req obj = new UpLoadTftpFile_Obj_req("download_tftp_file", "2.0", id, srcaddr_p, targetpath_p, srcfile_p);

            sdSysMgrService.OpretationStateSet(obj);
            return id;

        }

        public int SetAutoStartUpState(string state)
        {
            int id = idMfr.getNextIdent();
            stateChangeSet_Obj_req obj = new stateChangeSet_Obj_req("set_device_startup", "2.0", id, state);

            sdSysMgrService.OpretationStateSet(obj);
            return id;

        }
        public int SetAutoSave(string state)
        {
            int id = idMfr.getNextIdent();
            AutosaveSet_Obj_req obj = new AutosaveSet_Obj_req("set_auto_save", "2.0", id, state);

            sdSysMgrService.SetAutoSave(obj);
            return id;

        }

        public int Set_detail_log(string state)
        {
            int id = idMfr.getNextIdent();
            AutosaveSet_Obj_req obj = new AutosaveSet_Obj_req("set_detailed_log", "2.0", id, state);

            sdInputService.SetAutoSave(obj);
            //sdInputService.
            //sd .SetAutoSave(obj);
            return id;

        }

        public int SetReboot()
        {
            int id = idMfr.getNextIdent();
            stateReboot_Obj_req obj = new stateReboot_Obj_req("trigger_reboot", "2.0", id);

            sdSysMgrService.OpretationStateSet(obj);
            return id;

        }


        public int SetPowerOff()
        {
            int id = idMfr.getNextIdent();
            stateReboot_Obj_req obj = new stateReboot_Obj_req("set_power_off", "2.0", id);

            sdSysMgrService.OpretationStateSet(obj);
            return id;

        }

        #endregion


        #region Picture Tab commands
        public int SetContrast(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_contrast", "2.0", id, val, 0);

            sdPanelService.General_int_set(obj);
            //sdSysMgrService.General_int_set(obj);
            return id;

        }

        public int SetBackLightBoost(string state)
        {
            int id = idMfr.getNextIdent();
            BackLightBoost_Set_Obj_req obj = new BackLightBoost_Set_Obj_req("set_backlight_boost", "2.0", id, state,0);

            sdPanelService.General_int_set(obj);
            //sdSysMgrService.General_int_set(obj);
            return id;

        }

        public int SetRedGain(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_red_gain", "2.0", id, val, 0);

            sdPanelService.General_int_set(obj);
            //sdSysMgrService.General_int_set(obj);
            return id;

        }

        public int SetGreenGain(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_green_gain", "2.0", id, val, 0);

            sdPanelService.General_int_set(obj);
            //sdSysMgrService.General_int_set(obj);
            return id;

        }

        public int SetBlueGain(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_blue_gain", "2.0", id, val, 0);

            sdPanelService.General_int_set(obj);
            //sdSysMgrService.General_int_set(obj);
            return id;

        }

        public int SetBrightness(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_brightness", "2.0", id, val, 0);

            sdPanelService.General_int_set(obj);
            return id;

        }

        public int SetBackLight(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_backlight", "2.0", id, val, 0);

            sdPanelService.General_int_set(obj);
            return id;

        }

        public int SetBackLight_via_cs(int val)
        {
            int id = idMfr.getNextIdent();
            General_int_Set_Obj_req obj = new General_int_Set_Obj_req("set_backlight", "2.0", id, val, 0);


            sdColorService.General_int_set(obj);
            return id;

        }


        public int GetRedGain()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_red_gain", "2.0", id,0);

            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetRedOffset()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_red_offset", "2.0", id, 0);

            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetGreenOffset()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_green_offset", "2.0", id, 0);

            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetBlueOffset()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_blue_offset", "2.0", id, 0);

            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetGreenGain()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_green_gain", "2.0", id,0);
            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetBlueGain()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_blue_gain", "2.0", id,0);
            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetContrast()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_contrast", "2.0", id,0);

            sdPanelService.GeneralGet(obj);
            return id;

        }


        public int GetBackLight()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_backlight", "2.0", id,0);

            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetBackLight_Via_cs()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_backlight", "2.0", id, 0);

            sdColorService.GeneralGet(obj);
            return id;

        }

        public int GetBrightness()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_brightness", "2.0", id,0);

            sdPanelService.GeneralGet(obj);
            return id;

        }

        public int GetKortexActiveSource()
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req("get_active_source", "2.0", id,0);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }


        


        public int SetKortexSourceType(string  source)
        {
            int id = idMfr.getNextIdent();
            SourceSetobj_req obj = new SourceSetobj_req("set_active_source", "2.0", id, source, 0);
            sdSysMgrService.Chnage_ActiveSource(obj);
            return id;
            

         

        }


        public int GetMstarFmwVersion()
        {
            int id = idMfr.getNextIdent();
            General_Fmw_vertion_getobj_req obj = new General_Fmw_vertion_getobj_req("get_fmw_version", "2.0", id, 0);

            //sdSysMgrService.GeneralGet(obj);
            sdPanelService.GeneralGet(obj);

            return id;

        }


        public int GetGeneric_input(string rpc)
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req(rpc, "2.0", id, 0);

            //sdSysMgrService.GeneralGet(obj);

            sdInputService.GeneralGet(obj);

            return id;

        }

        public int GetCalib_XYZ_device(string dev)
        {
            int id = idMfr.getNextIdent();                              
            CS_Calibrate_XYZ_dev_req obj = new CS_Calibrate_XYZ_dev_req("calibrated_XYZ_measurement", "2.0", id, dev);
            sdColorService.GeneralGet(obj);
            return id;

        }

        public int GetGeneric_ColorSensor(string rpc)
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req(rpc, "2.0", id, 0);

            sdColorService.GeneralGet(obj);

            return id;

        }

        public int SetGeneric_SysMgr(string rpc)
        {
            int id = idMfr.getNextIdent();
            General_getobj_req obj = new General_getobj_req(rpc, "2.0", id,0);

            sdSysMgrService.GeneralGet(obj);
            //sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int GetGeneric_SysMgr(string rpc)
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req(rpc, "2.0", id, 0);

            //sdSysMgrService.GeneralGet(obj);
            sdSysMgrService.GeneralGet(obj);
            return id;
        }

        public int GetLogMessage(string LineNum)
        {
            int id = idMfr.getNextIdent();
            GetLogMessages_obj_req obj = new GetLogMessages_obj_req("get_logmsg", "2.0", id,  LineNum);

            //sdSysMgrService.GeneralGet(obj);
            sdSysMgrService.GeneralGet(obj);
            return id;
        }

        public int GetDianosticMessage(string LineNum)
        {
            int id = idMfr.getNextIdent();
            GetLogMessages_obj_req obj = new GetLogMessages_obj_req("get_diagnosis_result_line", "2.0", id, LineNum);

            //sdSysMgrService.GeneralGet(obj);
            sdSysMgrService.GeneralGet(obj);
            return id;
        }


        public int GetGetLockStatus()
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req("get_genlock_bypass_status", "2.0", id, 0);

            //sdSysMgrService.GeneralGet(obj);
            sdInputService.GeneralGet(obj);

            return id;

        }

        public int GetMercuryActiveSource()
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req("get_active_input", "2.0", id, 0);

            //sdSysMgrService.GeneralGet(obj);
            sdInputService.GeneralGet(obj);
            
            return id;

        }


        public int GetMercurySelectedSource()
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req("get_selected_input", "2.0", id, 0);

            //sdSysMgrService.GeneralGet(obj);
            sdInputService.GeneralGet(obj);
            

            return id;

        }




        public int GetFanRpm(string fan)
        {
            int id = idMfr.getNextIdent();
            GetFanSpeed_req obj = new GetFanSpeed_req("get_fan_rpm", "2.0", id, fan);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int GetFanSpeed(string fan)
        {
            int id = idMfr.getNextIdent();
            GetFanSpeed_req obj = new GetFanSpeed_req("get_fan_speed", "2.0", id, fan);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int GetFanTicks(string fan)
        {
            int id = idMfr.getNextIdent();
            GetFanSpeed_req obj = new GetFanSpeed_req("get_fan_ticks", "2.0", id, fan);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int GetIntegrationTime(int sensor)
        {
            int id = idMfr.getNextIdent();
            GetColorSensorIntigrationTime_req obj = new GetColorSensorIntigrationTime_req("get_col_sensor_intgr_time", "2.0", id, sensor);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int GetColorMeasurment(int Sensor,string color)
        {
            int id = idMfr.getNextIdent();
            GetColorSensorMeasurement_req obj = new GetColorSensorMeasurement_req("get_col_sensor_measurement", "2.0", id, Sensor, color);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }


        public int GetTemprature(string sensor)
        {
            int id = idMfr.getNextIdent();
            GetTemprature_req obj = new GetTemprature_req("get_temperature", "2.0", id, sensor);

            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int Get_CSRaw_count_()
        {
            int id = idMfr.getNextIdent();
            GetCS_Raw_count_req obj = new GetCS_Raw_count_req("get_raw_cs_count", "2.0", id, 0);
            sdColorService.GeneralGet(obj);
            return id;
        }

        public int Get_CSRaw_mes_cis()
        {
            int id = idMfr.getNextIdent();
            GetCS_Raw_count_req obj = new GetCS_Raw_count_req("measure_raw_cis", "2.0", id, 0);
            sdColorService.GeneralGet(obj);
            return id;
        }

        public int Get_CS_backLIght_get()
        {
            int id = idMfr.getNextIdent();
            GetCS_backLIght_req obj = new GetCS_backLIght_req("blklight_measurement", "2.0", id, 0);
            sdColorService.GeneralGet(obj);
            return id;
        }

        public int Get_CS_backLIght_update_get()
        {
            int id = idMfr.getNextIdent();
            GetCS_backLIght_req obj = new GetCS_backLIght_req("blklight_measurement", "2.0", id, 1);
            sdColorService.GeneralGet(obj);
            return id;
        }

        


        public int SetWallFullScrean(string state)
        {
            int id = idMfr.getNextIdent();
            WallScreanSetobj_req obj = new WallScreanSetobj_req("set_wall_conf_sts", "2.0", id, state);
            sdInputService.General_set(obj);
            return id;


        }

        public int SetColor_sensor_BackLight_status(string state)
        {
            int id = idMfr.getNextIdent();
            WallScreanSetobj_req obj = new WallScreanSetobj_req("set_bklight_status", "2.0", id, state);

            sdColorService.General_set(obj);
            return id;


        }


        public int SetColor_sensor_Mes_Loop_time(string status,string intval)
        {
            int id = idMfr.getNextIdent();
            CS_LoopTime_req obj = new CS_LoopTime_req("cs_measurement_loop", "2.0", id, status, intval);

            sdColorService.General_set(obj);
            return id;


        }


        public int Set_External_Ref_data(string rpc,
                                        string timeStamp,
                                        string ProdData,
                                        string ProcessVerion,
                                        double red_x,
                                        double red_y,
                                        double red_z,
                                        double green_x,
                                        double green_y,
                                        double green_z,
                                        double blue_x,
                                        double blue_y,
                                        double blue_z
                                        )
        {
            int id = idMfr.getNextIdent();
            ext_ref_data_req obj = new ext_ref_data_req(rpc, "2.0", id, timeStamp,
                                                 ProdData,
                                                 ProcessVerion,
                                                 red_x,
                                                 red_y,
                                                 red_z,
                                                 green_x,
                                                 green_y,
                                                 green_z,
                                                 blue_x,
                                                 blue_y,
                                                 blue_z);

            sdColorService.General_set(obj);
            return id;


        }

        public int Set_user_targetControl_data(int colorTemp, double locusOffset, string gammaFactor, int brightness)
        {
            int id = idMfr.getNextIdent();
            SetUserTargetCOntrol_paramsobj_req obj = new SetUserTargetCOntrol_paramsobj_req("set_user_target_control_params", "2.0", id, colorTemp,
                                                 locusOffset,
                                                 gammaFactor,
                                                 brightness);

            sdColorService.General_set(obj);
            return id;


        }

        public int Set_white_Balance(double delta_x, double delta_y, double delta_z)
        {
            int id = idMfr.getNextIdent();
            SetWhiteBalanceobj_req obj = new SetWhiteBalanceobj_req("set_white_balance", "2.0", id, delta_x, delta_y, delta_z);

            sdColorService.General_set(obj);
            return id;


        }


        public int Set_cbm_mode(string mode)
        {
            int id = idMfr.getNextIdent();
            WallConfigSetobj_req obj = new WallConfigSetobj_req("set_cbm_mode", "2.0", id, mode);

            sdColorService.General_set(obj);
            return id;


        }

        public int Set_cbm_params(int backlight_P,
                                int rOffset_P,
                                int gOffset_P,
                                int bOffset_P,
                                int rGain_P,
                                int gGain_P,
                                int bGain_P
                                )
        {
            //{ "backlight": 20, "rOffset": 20, "gOffset": 20, "bOffset": 20, "rGain": 20, "gGain": 20, "bGain": 20 }
            int id = idMfr.getNextIdent();
            cbmModeParamsSetobj_req obj = new cbmModeParamsSetobj_req("set_cbm_native_params", "2.0", id, backlight_P, rOffset_P, gOffset_P, bOffset_P, rGain_P, gGain_P, bGain_P);

            sdColorService.General_set(obj);
            return id;


        }

        public int Set_BlackWhite_level(string rpc,int backlight_P )
        {
            //{ "backlight": 20, "rOffset": 20, "gOffset": 20, "bOffset": 20, "rGain": 20, "gGain": 20, "bGain": 20 }
            int id = idMfr.getNextIdent();
            Pic_BlankingOffsetSetobj_req obj = new Pic_BlankingOffsetSetobj_req(rpc , "2.0", id, backlight_P);

            sdColorService.General_set(obj);
            return id;


        }
        

        public int Set_internal_Ref_data(string rpc)
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req(rpc, "2.0", id, 0);
            sdColorService.GeneralGet(obj);
            return id;
        }

        public int Setops_Operation(string state)
        {
            int id = idMfr.getNextIdent();
            OpsSetOperationobj_req obj = new OpsSetOperationobj_req("set_ops_operation", "2.0", id, state);
            sdSysMgrService.General_set(obj);
            return id;


        }


        public int SetWallConfig(string mode)
        {
            int id = idMfr.getNextIdent();
            WallConfigSetobj_req obj = new WallConfigSetobj_req("set_wall_config_mode", "2.0", id, mode);
            sdInputService.General_set(obj);
            return id;



        }

        public int SetPattern(string pattern)
        {
            int id = idMfr.getNextIdent();
            PattrenSetobj_req obj = new PattrenSetobj_req("set_pattern", "2.0", id, pattern);
            sdInputService.General_set(obj);
            return id;


        }

        public int GetWallConfig()
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req("get_wall_config_mode", "2.0", id, 0);

            sdInputService.GeneralGet(obj);
            return id;

        }


        public int SetBackgroundColor(string bakColor,int r,int g,int b)
        {
            int id = idMfr.getNextIdent();
            BackGround_setobj_req obj = new BackGround_setobj_req("set_background", "2.0", id, bakColor,r,g,b);
            sdInputService.General_set(obj);
            
            return id;


        }

        public int SetColorSensor_params(int gain,int prescaler,string period,string pulses)
        {
            int id = idMfr.getNextIdent();
            ColorSensorParams_setobj_req obj = new ColorSensorParams_setobj_req("set_cs_params", "2.0", id, gain, prescaler, period, pulses);
            sdColorService.General_set(obj);
            return id;


        }


        public int ReSetField_calibration(string rpc)
        {
            int id = idMfr.getNextIdent();
            Reset_CS_field_Calibration_obj_req obj = new Reset_CS_field_Calibration_obj_req(rpc, "2.0",id, 1);

            sdColorService.General_set(obj);
            return id;


        }

        public int GetBackgroundColor()
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req("get_background", "2.0", id, 0);

            sdInputService.GeneralGet(obj);
            return id;

        }

        public int GetWallFullScrean()
        {
            int id = idMfr.getNextIdent();
            General_Mercurygetobj_req obj = new General_Mercurygetobj_req("get_wall_conf_sts", "2.0", id, 0);

            sdInputService.GeneralGet(obj);
            return id;

        }

        public int GetInputTiming(string channel)
        {
            int id = idMfr.getNextIdent();
            GetInput_channel_timing_obj_req obj = new GetInput_channel_timing_obj_req("get_input_parameters", "2.0", id, channel);

            sdInputService.GeneralGet(obj);
            return id;

        }

        
        public int GetWallGeometry(string input_p)
        {
            int id = idMfr.getNextIdent();
            MercurywallGeometry_get_obj_req obj = new MercurywallGeometry_get_obj_req("get_wall_config", "2.0", id,  input_p);

            sdInputService.GeneralGet(obj);
            return id;

        }



        public int SetWallGeometry(int x,int y,int x_max,int yMax,string input_p,string mode_p)
        {
            
            int id = idMfr.getNextIdent();
            MercurywallGeometry_req obj = new MercurywallGeometry_req("set_wall_config", "2.0", id, x, y, x_max, yMax, input_p, mode_p);
            sdInputService.General_set(obj);
            return id;


        }
        public int SetMercurySourceType(string source)
        {
            int id = idMfr.getNextIdent();
            MercurySourceSetobj_req obj = new MercurySourceSetobj_req("set_selected_input", "2.0", id, source);
            //sdSysMgrService.Chnage_ActiveSource(obj);
            sdInputService.Chnage_ActiveSource(obj);
            return id;


        }

        public int SetMstarSourceShow()
        {
            int id = idMfr.getNextIdent();
            mstar_videoSetobj_req obj = new mstar_videoSetobj_req("set_mercury_video", "2.0", id, 0,0);
            //sdSysMgrService.Chnage_ActiveSource(obj);
            sdPanelService.Chnage_ActiveSource(obj);
            return id;


        }



        


        public int SetFanSpeed(string fan,int speed)
        {
            int id = idMfr.getNextIdent();
            FanSpeedSetobj_req obj = new FanSpeedSetobj_req("set_fan_speed", "2.0", id, fan, speed);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }

        public int SetIntigrationTime(int time, int sensor)
        {
            int id = idMfr.getNextIdent();
            Pic_IntigrationTimeSetobj_req obj = new Pic_IntigrationTimeSetobj_req("set_col_sensor_intgr_time", "2.0", id, sensor, time);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }


        public int SetBlankingOffset(int offset)
        {
            int id = idMfr.getNextIdent();
            Pic_BlankingOffsetSetobj_req obj = new Pic_BlankingOffsetSetobj_req("set_blanking_offset", "2.0", id, offset);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }


        #endregion

        #region Image Tab Commands

        public int Get_clock_status(string input)
        {
            int id = idMfr.getNextIdent();
            GetOpticalDvi_req obj = new GetOpticalDvi_req("get_clock_status", "2.0", id, input);
            sdInputService.GeneralGet(obj);
            return id;

        }

        public int Get_scm_status(string input_ch)
        {
            int id = idMfr.getNextIdent();
            Get_ScmStatus_req obj = new Get_ScmStatus_req("get_scm_status", "2.0", id, input_ch);
            sdInputService.GeneralGet(obj);
            return id;

        }

        public int Get_wall_status(string input_ch)
        {
            int id = idMfr.getNextIdent();
            Get_ScmStatus_req obj = new Get_ScmStatus_req("get_wall_active", "2.0", id, input_ch);
            sdInputService.GeneralGet(obj);
            return id;

        }

        public int GetVideoByPass(string input)
        {
            int id = idMfr.getNextIdent();
            GetOpticalDvi_req obj = new GetOpticalDvi_req("get_video_bypass_cmd_value", "2.0", id, input);
            sdInputService.GeneralGet(obj);
            return id;

        }

        public int SetVideoByPass(string input, string command)
        {
            int id = idMfr.getNextIdent();
            SetVideoBypass_req obj = new SetVideoBypass_req("set_video_bypass_cmd_value", "2.0", id, input, command);
            sdInputService.GeneralSet(obj);
            return id;

        }

        public int GetDviOptical(string input)
        {
            int id = idMfr.getNextIdent();
            GetOpticalDvi_req obj = new GetOpticalDvi_req("get_optical_dvi", "2.0", id, input);
            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int SetDviOptical(string input,string status)
        {
            int id = idMfr.getNextIdent();
            SetOpticalDvi_req obj = new SetOpticalDvi_req("set_optical_dvi", "2.0", id, input, status);
            sdSysMgrService.GeneralSet(obj);
            return id;

        }


        public int Setedid(string input, string edidtype_P, string path)
        {
            int id = idMfr.getNextIdent();
            SetEDID_obj_req obj = new SetEDID_obj_req("set_edid_data", "2.0", id, input, edidtype_P, path);

            sdInputService.GeneralSet(obj);
            return id;
        }


        public int Verifyedid(string input,  string path)
        {
            int id = idMfr.getNextIdent();
            VerifyEDID_obj_req obj = new VerifyEDID_obj_req("verify_edid_data", "2.0", id, input, path);

            sdInputService.GeneralSet(obj);
            return id;
        }


        #endregion



        #region Network IF

        public int GetNetworkIf(string eth)
        {
            int id = idMfr.getNextIdent();
            GetMacAddress_req obj = new GetMacAddress_req("get_net_setting", "2.0", id, eth);
            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int GetNetInfo(string eth)
        {
            int id = idMfr.getNextIdent();
            GetMacAddress_req obj = new GetMacAddress_req("get_net_info", "2.0", id, eth);
            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        public int SetNetworkIf(string eth, string addressing_p, string ip_p, string netmask_p)
        {
            int id = idMfr.getNextIdent();
            SetNetIFobj_req obj = new SetNetIFobj_req("set_net_setting", "2.0", id, eth, addressing_p, ip_p, netmask_p);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }


        public int GetMacAddress(string eth)
        {
            int id = idMfr.getNextIdent();
            GetMacAddress_req obj = new GetMacAddress_req("get_mac_addr", "2.0", id, eth);
            sdSysMgrService.GeneralGet(obj);
            return id;

        }


        public int SetMacAddress(string eth, string addr)
        {
            int id = idMfr.getNextIdent();
            SetMacAddressobj_req obj = new SetMacAddressobj_req("set_mac_addr", "2.0", id, eth, addr);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }

        #endregion


        #region Database 

        public int GetBid(string bid,string field)
        {
            int id = idMfr.getNextIdent();
            GetBid_req obj = new GetBid_req("get_board_id", "2.0", id, bid, field);
            sdSysMgrService.GeneralGet(obj);
            return id;

        }


        public int Setbid(string dev, string field,string val)
        {
            int id = idMfr.getNextIdent();
            SetBid_obj_req obj = new SetBid_obj_req("set_board_id", "2.0", id, dev, field, val);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }


        public int Test_Memory(string dev)
        {
            int id = idMfr.getNextIdent();
            //
            TestMemory_obj_req obj = new TestMemory_obj_req(dev, "2.0", id);

            sdSysMgrService.GeneralSet(obj);
            return id;


        }

        #endregion


        #region FMW tab commands

        public int GetModuleVersion(string modueaname)
        {
            int id = idMfr.getNextIdent();
            GetModuleVersion_req obj = new GetModuleVersion_req("get_firmware_version", "2.0", id, modueaname);
            sdSysMgrService.GeneralGet(obj);
            return id;

        }

        #endregion


        #region Color Sensor tab


        public int Getfpga_reg(string addr)
        {
            int id = idMfr.getNextIdent();
            Getfpga_reg_req obj = new Getfpga_reg_req("get_fpga_register", "2.0", id, addr);
            sdFpgaService.GeneralGet(obj);
            return id;

        }


        public int Setfpga_reg(int addr, int val)
        {
            int id = idMfr.getNextIdent();
            SetFpgaReg_obj_req obj = new SetFpgaReg_obj_req("set_fpga_register", "2.0", id, addr, val);

            sdFpgaService.GeneralSet(obj);
            
            return id;


        }



        #endregion

    }
}
